/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Ruang;

import java.util.ArrayList;
import java.util.List;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author advent
 */
public class RuangTableModel extends AbstractTableModel{

   private List<Ruang> ruang = new ArrayList<Ruang>();

    public RuangTableModel(List <Ruang> ruang) {
        this.ruang = ruang;
    }

    public void delete(int row){
        ruang.remove(row);
        fireTableRowsDeleted(row, row);
    }

    public void update(int row, Ruang kat) {
       ruang.set(row, kat);
       fireTableRowsUpdated(row, row);
    }


    public int getRowCount() {
        return ruang.size();
    }

    public int getColumnCount() {
        return 1;
    }

    public Object getValueAt(int rowIndex, int columnIndex) {
        Ruang k = ruang.get(rowIndex);
        switch (columnIndex) {
            case 0:
                return k.getId_ruang();
            default:
                return "";
        }
    }

    @Override
        public String getColumnName(int column) {
        switch (column) {
            case 0:
                return "Id Ruang";
            default:
                return "";
        }
    }


}
